package com.hw.common.enums;


import cn.hutool.core.util.StrUtil;

import java.util.LinkedHashMap;
import java.util.Map;

public enum TimePartitionEnum {
    YEAR("year", "年", "yyyy", 1),
    MONTH("month", "月", "yyyy-MM", 2),
    DAY("day", "日", "yyyy-MM-dd", 5),
    HOUR("hour", "小时", "yyyy-MM-dd HH", 11),
    MINUTE("minute", "分", "yyyy-MM-dd HH:mm", 12);

    private String code;
    private String name;
    private String pattern;
    private int calendarConst;

    public static TimePartitionEnum getByCode(String code) {
        if (StrUtil.isEmpty(code)) {
            return null;
        } else {
            TimePartitionEnum[] var1 = values();
            int var2 = var1.length;

            for(int var3 = 0; var3 < var2; ++var3) {
                TimePartitionEnum timePartition = var1[var3];
                if (StrUtil.equals(code, timePartition.getCode())) {
                    return timePartition;
                }
            }

            return null;
        }
    }

    public static Map<String, String> findTimePartitionList() {
        Map<String, String> map = new LinkedHashMap();
        TimePartitionEnum[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            TimePartitionEnum timePartitionEnum = var1[var3];
            map.put(timePartitionEnum.getCode(), timePartitionEnum.getName());
        }

        return map;
    }

    private TimePartitionEnum(String code, String name, String pattern, int calendarConst) {
        this.code = code;
        this.name = name;
        this.pattern = pattern;
        this.calendarConst = calendarConst;
    }

    public String getCode() {
        return this.code;
    }

    public String getName() {
        return this.name;
    }

    public String getPattern() {
        return this.pattern;
    }

    public int getCalendarConst() {
        return this.calendarConst;
    }
}
